db_common: &db_common
  methods:
    - probe_db
  opts:
    connection_string: <%= @connection_string %>

# Web server config
server:
  listen_address: <%= node['monitoring']['gitlab-exporter']['listen_address'] %>
  listen_port: <%= node['monitoring']['gitlab-exporter']['listen_port'] %>

# Probes config
probes:
  git_process: &git_process
    class_name: GitProcessProber # `class_name` is redundant here
    methods:
    - probe_git
    opts:
      quantiles: true

<% if node['gitlab']['gitlab-rails']['db_adapter'] == 'postgresql' -%>
  # We can group multiple probes under a single endpoint by setting the `multiple` key to `true`, followed
  # by probe definitions as usual.
  database:
    multiple: true
    ci_builds:
      class_name: Database::CiBuildsProber
      <<: *db_common
    tuple_stats:
      class_name: Database::TuplesProber
      <<: *db_common
    rows_count:
      class_name: Database::RowCountProber
      <<: *db_common
<% end -%>

  process: &process
    methods:
      - probe_stat
      - probe_count
    opts:
      - pid_or_pattern: "sidekiq .* \\[.*?\\]"
        name: sidekiq
      - pid_or_pattern: "gitlab-puma-worker"
        name: puma
      - pid_or_pattern: "unicorn.* worker\\[.*?\\]"
        name: unicorn
      - pid_or_pattern: "git-upload-pack --stateless-rpc"
        name: git_upload_pack
        quantiles: true

<% if @probe_sidekiq %>
  sidekiq: &sidekiq
    methods:
      - probe_stats
      - probe_queues
      - probe_workers
      - probe_retries
    opts:
      redis_url: "<%= @redis_url %>"
      redis_enable_client: <%= @redis_enable_client %>
<% end %>

  metrics:
    multiple: true
    git_process:
      <<: *git_process
    process:
      <<: *process
<% if @probe_sidekiq %>
    sidekiq:
      <<: *sidekiq
<% end %>
<% if node['gitlab']['gitlab-rails']['db_adapter'] == 'postgresql' -%>
    ci_builds:
      class_name: Database::CiBuildsProber
      <<: *db_common
    tuple_stats:
      class_name: Database::TuplesProber
      <<: *db_common
    rows_count:
      class_name: Database::RowCountProber
      <<: *db_common
<% end -%>
